public class 无重复字符最长子串 {
    
    public static void main(String[] args) {
        
        int len = lengthOfLongestSubstring("abcabcbb");

        System.out.println("len:="+len);

    }

    private static int lengthOfLongestSubstring(String s) {

        if(null==s || s.length() < 1) return 0;

        int maxLen = 1;
        int[] temp = new int[128];
        int start = 0;

        for(int end=0; end<s.length(); end++){

            char c = s.charAt(end);
            start = Math.max(start, temp[c]);
            maxLen = Math.max(maxLen, end - start +1);

            temp[c] = end+1;

        }

        return maxLen;

    }
}
